/**
 * Created by Administrator on 2018/1/18.
 */

layui.use(['jquery', 'laydate','form','layer','laypage','table'], function(){
    var $ = layui.jquery,
        laydate = layui.laydate,
        layer = layui.layer,
        table = layui.table,
        form = layui.form;

    laydate.render({
        elem: '#start'//指定元素
    });

    laydate.render({
        elem: '#end' //指定元素

    });

    var under_config = {
        elem: '#investor',
        url:"/proxy/investor",
        method:'post',
        cellMinWidth:80,
        cols:  [[
            //标题栏
            {field: 'id', title: '用户ID',align: 'center'},
            {field: 'name', title: '客户姓名',align: 'center'},
            {field: 'isproxy', title: '是否代理',align: 'center'},
            {field: 'pid', title: '所属代理',align: 'center'},
            {field: 'ppid', title: '上级代理',align: 'center'},
            {field: 'phone', title: '手机号码',align: 'center'},
            {field: 'register_time', title: '注册时间',align: 'center'},
            {field: 'remark', title: '备注',align: 'center',width: 150},
            //{fixed: 'right', align:'center', title: '操作',toolbar: '#barDemo', width: 250}
        ]],
        //data:data.data,
        page: true,
        limit: 10,
        height: 680,
        done: function(res, curr, count){
             layer.closeAll();
             $('#pid').html(res.extra.proxy_option);
             $('#uid').html(res.extra.user_option);
             form.render('select');
        }
    };

    //方法级渲染-默认显示入金记录
    var ins1 = table.render(under_config);

    //表格搜索和重载
    var $ = layui.$,
        active = {
        reload: function(){
            var index = layer.msg('数据加载中,请耐心等待...', {
                icon: 16,shade: 0.5,time:15000
            });

            var uid = $('#uid').val();
            var pid = $('#pid').val();
            var start_time = $('#start').val();
            var end_time = $('#end').val();

            ins1.reload({
                where: {
                    //根据MT4搜索
                    pid:pid,
                    uid:uid,
                    status:status,
                    start_time:start_time,
                    end_time:end_time
                }
            });
        }
    };

    $('.content-search .layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });

});
